package com.game.gui {
	import com.game.data.Data;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.filters.BlurFilter;
	public class GeneralButton extends Sprite {
		private var _active:Boolean = false;
		private var _onShape:Shape = new Shape();
		private var _stateOne:BitmapData;
		private var _stateTwo:BitmapData;
		public function GeneralButton(stateOne:BitmapData = null, stateTwo:BitmapData = null) {
			_stateOne = stateOne;
			_stateTwo = stateTwo;
			draw();
			var sz:int = Data.ICON_SIZE - 18;
			_onShape.graphics.lineStyle(3, 0xFF9900);
			_onShape.graphics.drawCircle(Data.ICON_SIZE / 2, Data.ICON_SIZE / 2, sz / 2);
			this.mouseChildren = false;
			this.buttonMode = true;
		}
		public function over(value:Boolean):void {
			if (_onShape.stage) {
				this.removeChild(_onShape);
			}
			_onShape.filters = []
			if (value) {
				this.addChild(_onShape);
				_onShape.filters = [new BlurFilter(5, 5, 2)]
			}
		}
		public function get active():Boolean {
			return _active;
		}
		public function set active(value:Boolean):void {
			_active = value;
			draw();
		}
		private function draw():void {
			this.graphics.clear();
			if (_active && _stateTwo) {
				this.graphics.beginBitmapFill(_stateTwo,null,false,true);
			} else {
				this.graphics.beginBitmapFill(_stateOne,null,false,true);
			}
			this.graphics.drawRect(0, 0, Data.ICON_SIZE, Data.ICON_SIZE);
			this.graphics.endFill();
		}
	}
}